package com.qilin.hscs.redis;

import redis.clients.jedis.Jedis;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * Created by 10188 on 2018/4/26.
 */
public class JedisTemplate {

    private Jedis jedis;
    private static final int port=6379;
    private static String host="127.0.0.1";
    public void connect() {
        jedis = new Jedis(host, port);
        jedis.connect();
    }

    public boolean set(String key,String val) {
        String set = jedis.set(key, val);
        if (set != null) {
            return true;
        }
        return false;
    }

    public boolean del(String key) {
        Long del = jedis.del(key);
        if (del > 0) {
            return true;
        }
        return false;
    }

    public String get(String key) {
        return jedis.get(key);
    }

    public boolean isExist(String key) {
        return jedis.exists(key);
    }
}
